class PercentageCommissionPolicyController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def list = {
        if(!params.max) params.max = 10
        [ percentageCommissionPolicyInstanceList: PercentageCommissionPolicy.list( params ) ]
    }

    def show = {
        def percentageCommissionPolicyInstance = PercentageCommissionPolicy.get( params.id )

        if(!percentageCommissionPolicyInstance) {
            flash.message = "PercentageCommissionPolicy not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ percentageCommissionPolicyInstance : percentageCommissionPolicyInstance ] }
    }

    def delete = {
        def percentageCommissionPolicyInstance = PercentageCommissionPolicy.get( params.id )
        if(percentageCommissionPolicyInstance) {
            percentageCommissionPolicyInstance.delete()
            flash.message = "PercentageCommissionPolicy ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "PercentageCommissionPolicy not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def percentageCommissionPolicyInstance = PercentageCommissionPolicy.get( params.id )

        if(!percentageCommissionPolicyInstance) {
            flash.message = "PercentageCommissionPolicy not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ percentageCommissionPolicyInstance : percentageCommissionPolicyInstance ]
        }
    }

    def update = {
        def percentageCommissionPolicyInstance = PercentageCommissionPolicy.get( params.id )
        if(percentageCommissionPolicyInstance) {
            percentageCommissionPolicyInstance.properties = params
            if(!percentageCommissionPolicyInstance.hasErrors() && percentageCommissionPolicyInstance.save()) {
                flash.message = "PercentageCommissionPolicy ${params.id} updated"
                redirect(action:show,id:percentageCommissionPolicyInstance.id)
            }
            else {
                render(view:'edit',model:[percentageCommissionPolicyInstance:percentageCommissionPolicyInstance])
            }
        }
        else {
            flash.message = "PercentageCommissionPolicy not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def percentageCommissionPolicyInstance = new PercentageCommissionPolicy()
        percentageCommissionPolicyInstance.properties = params
        return ['percentageCommissionPolicyInstance':percentageCommissionPolicyInstance]
    }

    def save = {
        def percentageCommissionPolicyInstance = new PercentageCommissionPolicy(params)
        if(!percentageCommissionPolicyInstance.hasErrors() && percentageCommissionPolicyInstance.save()) {
            flash.message = "PercentageCommissionPolicy ${percentageCommissionPolicyInstance.id} created"
            redirect(action:show,id:percentageCommissionPolicyInstance.id)
        }
        else {
            render(view:'create',model:[percentageCommissionPolicyInstance:percentageCommissionPolicyInstance])
        }
    }
}
